import { createRouter, createWebHistory } from 'vue-router'
import { setupRouterGuard } from './guard'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: () => import('@/views/Home.vue'),
    meta: { requiresAuth: true }
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/Login.vue'),
    meta: { requiresAuth: false }
  },
  {
    path: '/loginRole',
    name: 'LoginRole',
    component: () => import('@/views/LoginRole.vue'),
    meta: { requiresAuth: true }
  },
  {
    path: '/studyInfo',
    name: 'StudyInfo',
    component: () => import('@/views/StudyInfo.vue'),
    meta: { requiresAuth: true }
  },
  {
    path: '/studyTest',
    name: 'StudyTest',
    component: () => import('@/views/StudyTest.vue'),
    meta: { requiresAuth: true }
  },
  {
    path: '/evaluationResults',
    name: 'EvaluationResults',
    component: () => import('@/views/EvaluationResults.vue'),
    meta: { requiresAuth: true }
  },
  {
    path: '/dataCenter',
    name: 'DataCenter',
    component: () => import('@/views/DataCenter.vue'),
    meta: { requiresAuth: true }
  },
  {
    path: '/myAnswerSheet',
    name: 'MyAnswerSheet',
    component: () => import('@/views/MyAnswerSheet.vue'),
    meta: { requiresAuth: true }
  },
  {
    path: '/myAnswerSheetDetail',
    name: 'MyAnswerSheetDetail',
    component: () => import('@/views/MyAnswerSheetDetail.vue'),
    meta: { requiresAuth: true }
  },
  {
    path: '/answerQuestions',
    name: 'AnswerQuestions',
    component: () => import('@/views/AnswerQuestions.vue'),
    meta: { requiresAuth: true }
  },
  {
    path: '/mistakeNotebook',
    name: 'MistakeNotebook',
    component: () => import('@/views/MistakeNotebook.vue'),
    meta: { requiresAuth: true }
  },
  {
    path: '/trainingCenter',
    name: 'TrainingCenter',
    component: () => import('@/views/TrainingCenter.vue'),
    meta: { requiresAuth: true }
  },
]

const router = createRouter({
  history: createWebHistory(),
  routes
})



// 设置路由守卫
setupRouterGuard(router)

export default router